package com.ronan.client.handler;

import com.ronan.common.codec.RIMFrameDecoder;
import com.ronan.common.codec.RIMProtocolDecoder;
import com.ronan.common.codec.RIMProtocolEncoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * FileName    : com.ronan.client.handler
 * Description :
 *
 * @author : ronan
 * @version : 1.0
 * Create Date : 2021/3/1 16:55
 **/
public class RIMClientHandlerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel channel) throws Exception {
        ChannelPipeline pipeline = channel.pipeline();

        pipeline.addLast("LengthFieldBasedFrameDecoder", new RIMFrameDecoder());

        pipeline.addLast("encode", new RIMProtocolEncoder());
        pipeline.addLast("decode", new RIMProtocolDecoder());

        pipeline.addLast("biz", new RIMClientHandler());
    }
}
